import requests
import json

def received_data():
    '''接收每日数据'''
    urls = "https://c.m.163.com/ug/api/wuhan/app/data/list-total"

    headers = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'}

    initial_data = requests.get(url= urls, headers = headers)

    json_data = initial_data.json()['data'] #对网页返回的json文件进行初步的数据处理只保留数据

    #存储基础数据一份
    with open("E:\guan_quarantine\initial_data.txt" ,'w+', encoding="utf-8") as f:
        f.write(json.dumps(json_data
                            ,indent=4
                            , separators=(',', ': ')
                            ,ensure_ascii= False))  #设置参数indent，和separator用于格式化存储接送文件ensure_ascii用于处理中文显示

    return json_data